package com.mr.example3.friend;

import java.io.IOException;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

/*
 * 1.输入数据：(用户：好友，好友)
 * 		A:B,C,D,F,E,O
 *
 * 使用KeyValueTextInputFormat输入格式
 *
 * 2.输出数据：(好友	用户)，(好友	用户)
 * 		(B	A),(C	A),(D	A),(F	A),(E	A),(O	A)
 */

public class Example3Mapper1 extends Mapper<Text, Text, Text, Text>{

	@Override
	protected void map(Text key, Text value, Mapper<Text, Text, Text, Text>.Context context)
			throws IOException, InterruptedException {

		String[] friends = value.toString().split(",");

		for (String friend : friends) {

			context.write(new Text(friend), new Text(key));

		}

	}

}
